package com.lagou.edu.controller;

import com.lagou.edu.dao.AccountDao;
import com.lagou.edu.pojo.Account;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("/account")
public class AccountController {

    /**
     * Spring容器和SpringMVC容器是有层次的（父子容器）
     * Spring容器：service对象+dao对象
     * SpringMVC容器：controller对象，，，，可以引用到Spring容器中的对象
     */


    @Autowired
    private AccountDao accountDao;


    @RequestMapping("/login")
    public String queryAll(String userName, String passWord) throws Exception {

        Account account = new Account();
        account.setPassWord(passWord);
        account.setName(userName);
        Example<Account> example = Example.of(account);
        List<Account> accounts = accountDao.findAll(example);
        if (accounts != null && accounts.size() > 0) {
            return "redirect:/resume/queryAll";
        } else {

            return "redirect:/";
        }

    }

}
